home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbsnip.zip / DRVLST.BAS < prev    next >
BASIC Source File  |  1997-06-19  |  2KB  |  86 lines

  1. DEFINT A-Z
  2.  
  3. '$INCLUDE: 'qb.bi'
  4.  
  5. DECLARE FUNCTION FDList$ ()
  6. DECLARE FUNCTION HDList$ (FloppyList$)
  7.  
  8. 'Test Program
  9. CLS
  10. A$ = FDList$
  11. IF A$ <> "A" THEN
  12.     PRINT "Floppy drives are from A to "; A$
  13. ELSE
  14.     PRINT "Floppy Drive A installed."
  15. END IF
  16.  
  17. B$ = HDList$(FDList$)
  18. PRINT "Hard drives are from C to "; B$
  19.  
  20.  
  21. '***********************************************************************
  22. '* FUNCTION FDList$
  23. '*
  24. '* PURPOSE
  25. '*    PEEKs at the BIOS Equipment Word to return a list of floppy
  26. '*    drives installed on the system.
  27. '*
  28. '* CREDIT(S)
  29. '*    Larry Stone, based on a routine published in MicroHelp's BUG
  30. '*    Newsletter, 1/1/90.
  31. '*
  32. '*    Modified to use fixed-length strings.
  33. '***********************************************************************
  34. FUNCTION FDList$ STATIC
  35.      DEF SEG = 0
  36.      FD% = PEEK(&H410) \ 64 + 1                'How many FDs installed?
  37.      DEF SEG                                   'Restore DGROUP
  38.      FD$ = SPACE$(FD%)
  39.  
  40.      FOR N% = 1 TO FD%                         'Place these letters into
  41.             MID$(FD$, N%, 1) = CHR$(64 + N%)       '  FD$
  42.      NEXT
  43.  
  44.      FDList$ = FD$                             'Return value
  45.      FD$ = ""
  46. END FUNCTION
  47.  
  48. '***********************************************************************
  49. '* FUNCTION HDList$
  50. '*
  51. '* PURPOSE
  52. '*    Uses DOS ISR 21H, Function 44H, Subfunction 09H (Is Drive Remote)
  53. '*    to return a list of valid, local hard drives.
  54. '*
  55. '* CREDIT(S)
  56. '*    Larry Stone, based on a routine published in MicroHelp's BUG
  57. '*    Newsletter, 1/1/90.
  58. '*
  59. '*    Modified to use fixed-length strings.
  60. '***********************************************************************
  61. FUNCTION HDList$ (FloppyList$)
  62.      DIM IRegs AS RegType, ORegs AS RegType
  63.  
  64.      FloppyList$ = FDList$                     'Get floppy drive list
  65.      FDs% = LEN(FloppyList$)                   'How many drives found?
  66.  
  67.      HD% = FDs% + 1 + ABS(FD% = 1)             'If only 1 FD, first is C:
  68.      HD$ = SPACE$(HD%)
  69.  
  70.      FOR BL% = HD% TO 26                       'Check possible hard drives
  71.             IRegs.ax = &H4409                      'Set up call
  72.             IRegs.bx = BL%                         'Drive letter in BL
  73.             Interrupt &H21, IRegs, ORegs           'Call DOS
  74.  
  75.             IF (ORegs.flags AND 1) THEN            'Check carry flag
  76.                  EXIT FOR
  77.             END IF
  78.  
  79.             MID$(HD$, HD%, 1) = CHR$(64 + ORegs.bx)'Add the letter
  80.      NEXT
  81.  
  82.      HDList$ = RIGHT$(HD$, 1)                            'Return value
  83.      HD$ = ""
  84. END FUNCTION
  85.  
  86.